var bgjhdxl = {
    gridOptions:{
        url: $.webPath() + '/report/bgjhdxl/bgjhdxlList',
        toolbar: "#bgjhdxl-toolbar",
        rownumbers: true,
        singleSelect: true,
        pagination: true,
        fit: true,
        collapsible:true,
        fitColumns: false,
        frozenColumns:[[
            {field:'ywkmc',title:'业务科室',width:100,align:'center',rowspan:2},
            {field:'sm',title:'计划描述',width:200,align:'center',rowspan:2},
            {field:'wzmc',title:'物资名称',width:100,align:'center',rowspan:2},
            {field:'wzbm',title:'物资编码',width:100,align:'center',rowspan:2},
            {field:'wzgg',title:'物资规格',width:100,align:'center',rowspan:2}
        ]],
        columns:[
            [
                {field:'zt',title:'状态',width:80,align:'right',rowspan:2},
                {field:'cgfs',title:'采购方式',width:50,align:'right',rowspan:2},
                {field:'jhsl',title:'计划提报数量',width:80,align:'right',rowspan:2},
                {title:'供应站处理',width:80,align:'center',colspan:2},
                {title:'业务科处理',width:80,align:'center',colspan:3},
                {field:'cgfsqdsl',title:'采购方式确定数量',width:80,align:'right',rowspan:2},
                {field:'cghtqdsl',title:'合同签订数量',width:80,align:'right',rowspan:2},
                {field:'cgdkjsl',title:'采购单开具数量',width:80,align:'right',rowspan:2},
                {field:'cgdrksl',title:'到货数量',width:80,align:'right',rowspan:2},
                {field:'xsdcksl',title:'销售数量',width:80,align:'right',rowspan:2}
            ],
            [
                {field:'gyzphsl',title:'平衡数量',width:80,align:'right'},
                {field:'gyztjsl',title:'提交数量',width:80,align:'right'},
                {field:'ywksphsl',title:'平衡数量',width:80,align:'right'},
                {field:'pbwcsl',title:'配拨完成数量',width:80,align:'right'},
                {field:'tjcgsl',title:'提交采购数量',width:80,align:'right'}
            ]
        ]
    },
    grid:$("#bgjhdxl-datagrid"),
    init:function(){
        bgjhdxl.grid.datagrid(bgjhdxl.gridOptions);
        $("#bgjhdxl-toolbar input[name='nf']").numberspinner({
            min: 2000,
            max: 2100,
            editable: true
        });
        $("#bgjhdxl-toolbar input[name='yf']").numberspinner({
            min: 1,
            max: 12,
            editable: true
        });
        $("#bgjhdxl-toolbar [name='jhdw']").ljsxyCombobox({lx: 3, sxy: "xy", jyjg: $("#bgjhdxl-toolbar [name='zgsId']").val()});
        $("#bgjhdxl-toolbar input[name='gyz']").gyzcombobox();
    }
}

$(function(){
    bgjhdxl.init();
    $("#bgjhdxl-toolbar input:button").click(function(){
        bgjhdxl.grid.datagrid("load",{
            nf:$("#bgjhdxl-toolbar input[name='nf']").val(),
            yf:$("#bgjhdxl-toolbar input[name='yf']").val(),
            jhlx:$("#bgjhdxl-toolbar input[name='jhlx']").val(),
            jhdw:$("#bgjhdxl-toolbar input[name='jhdw']").val(),
            gyz:$("#bgjhdxl-toolbar input[name='gyz']").val(),
            wzbm:$("#bgjhdxl-toolbar input[name='wzbm']").val(),
            jhsm:$("#bgjhdxl-toolbar input[name='jhsm']").val()
        });
    });
    $("#bgjhdxl-toolbar a[name='export']").click(function(){
        if(!$("#bgjhdxl-toolbar input[name='jhsm']").val()) {
            $.messager.alert('警告','计划说明未填写!','warning');
            return;
        }
        $.post($.webPath() + "/report/bgjhdxl/existsJhsm",{jhsm:$("#bgjhdxl-toolbar input[name='jhsm']").val()},function(data){
            if(data == 'ok') {
                var obj = [{name:'nf',value:$("#bgjhdxl-toolbar input[name='nf']").val()},
                    {name:'yf',value:$("#bgjhdxl-toolbar input[name='yf']").val()},
                    {name:'jhlx',value:$("#bgjhdxl-toolbar input[name='jhlx']").val()},
                    {name:'jhdw',value:$("#bgjhdxl-toolbar input[name='jhdw']").val()},
                    {name:'gyz',value:$("#bgjhdxl-toolbar input[name='gyz']").val()},
                    {name:'wzbm',value:$("#bgjhdxl-toolbar input[name='wzbm']").val()},
                    {name:'jhsm',value:$("#bgjhdxl-toolbar input[name='jhsm']").val()}];
                window.location = $.webPath() + "/report/bgjhdxl/bgjhdxlExp?"+ $.param(obj);
            } else {
                $.messager.alert('警告','不存在计划说明!','warning');
            }
        });
//        window.open($.webPath() + "/report/bgjhdxl/bgjhdxlExp");
    });
});